package com.JingYan.enums;


import com.JingYan.service.TianLianVerificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.EnumSet;

/**
 * @program: iron-tcm-api
 * @ClassName: TianLingPresSerificationEnum.java
 * @author: DongJiaQi
 * @version: 1.0.0
 * @Description: 天灵对账处方对账枚举
 * @createTime 2023年09月20日 14:53:00
 */
public enum TianLingPresSerificationEnum {
    ZCFL("总处方量","1") {
        @Override
        public void execute(String checkMon) {
            tianLianVerificationService.presZcflCheck(checkMon);
        }
    };
    private final String typeName;
    private final String typeCode;

    private static TianLianVerificationService tianLianVerificationService;


    public String getTypeName() {
        return typeName;
    }

    public String getTypeCode() {
        return typeCode;
    }
    public void setTianLianVerificationService(TianLianVerificationService tianLianVerificationService) {
        TianLingPresSerificationEnum.tianLianVerificationService = tianLianVerificationService;
    }

    TianLingPresSerificationEnum(String typeName, String typeCode) {
        this.typeName = typeName;
        this.typeCode = typeCode;
    }

    /**
     * 对账执行方法
     * @param checkMon
     * @return
     */
    public abstract void execute(String checkMon);


    /**
     * 设置属性
     */
    @Component
    public static class SetTianLianVerificationService {
        @Autowired
        private TianLianVerificationService tianLianVerificationService;
        @PostConstruct
        public void setTianLianVerificationService() {
            for (TianLingPresSerificationEnum tianLingPresSerificationEnum: EnumSet.allOf(TianLingPresSerificationEnum.class)) {
                tianLingPresSerificationEnum.setTianLianVerificationService(tianLianVerificationService);
            }
        }

    }
}
